package app.server.project.main.service.db.entity.cfg;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import lombok.Data;
import org.hibernate.annotations.Comment;

@Data
@Entity(name = "global_cfg")
@TableName("global_cfg")
@Comment(value = "全局配置表")
public class GlobalCfgEntity {

    @Id
    @Column(name = "id")
    @Comment("配置主键")
    @TableId("id")
    private String id;


    @Column(name = "val", length = 10000000)
    @Comment("配置值")
    @TableField("val")
    private String val;

    @Column(name = "remark")
    @Comment("备注")
    @TableField("remark")
    private String remark;

    @JsonIgnore
    public long getLong() {
        return Long.parseLong(this.val);
    }

    @JsonIgnore
    public int getInt() {
        return Integer.parseInt(this.val);
    }

    @JsonIgnore
    public boolean getBool() {
        return Integer.parseInt(this.val) > 0;
    }
}
